# 测试学校信息控制器的各个端点
Write-Host "测试学校信息控制器 API..." -ForegroundColor Green

# 测试列表端点（匿名访问）
Write-Host "`n1. 测试 /jwgl/schoolinfo/list (匿名访问):" -ForegroundColor Yellow
try {
    $response = Invoke-RestMethod -Uri "http://localhost:8091/jwgl/schoolinfo/list" -Method GET -Headers @{"Accept"="application/json"}
    Write-Host "成功获取数据！" -ForegroundColor Green
    Write-Host "返回数据: $($response | ConvertTo-Json -Depth 3)"
} catch {
    Write-Host "错误: $($_.Exception.Message)" -ForegroundColor Red
    if ($_.Exception.Response) {
        $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())
        $reader.BaseStream.Position = 0
        $reader.DiscardBufferedData()
        $responseBody = $reader.ReadToEnd()
        Write-Host "响应内容: $responseBody" -ForegroundColor Red
    }
}

# 测试所有学校列表端点
Write-Host "`n2. 测试 /jwgl/schoolinfo/list/all:" -ForegroundColor Yellow
try {
    $response = Invoke-RestMethod -Uri "http://localhost:8091/jwgl/schoolinfo/list/all" -Method GET -Headers @{"Accept"="application/json"}
    Write-Host "成功获取数据！" -ForegroundColor Green
    Write-Host "返回数据: $($response | ConvertTo-Json -Depth 3)"
} catch {
    Write-Host "错误: $($_.Exception.Message)" -ForegroundColor Red
}

# 测试活跃学校端点
Write-Host "`n3. 测试 /jwgl/schoolinfo/active:" -ForegroundColor Yellow
try {
    $response = Invoke-RestMethod -Uri "http://localhost:8091/jwgl/schoolinfo/active" -Method GET -Headers @{"Accept"="application/json"}
    Write-Host "成功获取数据！" -ForegroundColor Green
    Write-Host "返回数据: $($response | ConvertTo-Json -Depth 3)"
} catch {
    Write-Host "错误: $($_.Exception.Message)" -ForegroundColor Red
}

Write-Host "`n测试完成！" -ForegroundColor Green